package com.bw.mallshop.bind;

import androidx.databinding.BindingAdapter;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;

public class CategoryBind {

    @BindingAdapter({"adapter","type"})
    public static void categoryBind(RecyclerView recyclerView, BaseQuickAdapter adapter,int type){
        if (type == 0){
            //左侧线性列表
            LinearLayoutManager manager = new LinearLayoutManager(recyclerView.getContext());
            manager.setOrientation(LinearLayoutManager.VERTICAL);
            recyclerView.setLayoutManager(manager);
        }else if (type == 1){
            //右侧网格列表
            GridLayoutManager manager = new GridLayoutManager(recyclerView.getContext(),3);
            manager.setOrientation(GridLayoutManager.VERTICAL);
            recyclerView.setLayoutManager(manager);
        }
        recyclerView.setAdapter(adapter);
    }

}
